package just.stuff.morsels.objects;

import java.io.Serializable;

import com.sleepycat.persist.model.DeleteAction;
import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.PrimaryKey;
import com.sleepycat.persist.model.Relationship;
import com.sleepycat.persist.model.SecondaryKey;

@Entity
public class AssistanceRequest implements Serializable {

	@PrimaryKey( sequence="assistanceId" )
	private Long id;
	@SecondaryKey( relate=Relationship.MANY_TO_ONE, relatedEntity=User.class, onRelatedEntityDelete=DeleteAction.CASCADE)
	private String from;
	@SecondaryKey( relate=Relationship.ONE_TO_ONE, relatedEntity=Morsel.class, onRelatedEntityDelete=DeleteAction.CASCADE)
	private String morselId;
	@SecondaryKey( relate=Relationship.MANY_TO_ONE )
	private Status status;
	

	public AssistanceRequest() {}
	
	public AssistanceRequest( User sender, Morsel morsel ) {
		this.from = sender.getId();
		this.morselId = morsel.getId();
		this.status = Status.SUBMITTED;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getMorselId() {
		return morselId;
	}

	public void setMorselId(String morselId) {
		this.morselId = morselId;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public static enum Status {
		SUBMITTED,
		ACTIVE;
	}
}
